Package MusicLandscape.util.comparators
Class MyTrackComparator
- java.lang.Object
-
- MusicLandscape.util.comparators.MyTrackComparator
-
- Direct Known Subclasses:
MyDurationComparator,MyTitleComparator
public abstract class MyTrackComparator extends java.lang.ObjectThis class represents the concept of comparison of two tracks. It has a single abstract method that is to be implemented by concrete subclasses which implement concrete modes of comparison, e.g. by title, by duration or other.- Version:
- 234
- Author:
- TeM, JS
- Stage:
- ES04
- Introduced in:
- ExerciseSheet04
- Programming problem category:
- abstract class
-
-
Constructor Summary
Constructors Constructor Description MyTrackComparator()
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description abstract intcompare(Track t1, Track t2)Compares two tracks.
-
-
-
Method Detail
-
compare
public abstract int compare(Track t1, Track t2)
Compares two tracks.
The result of the comparison of two tracks is a measure of "distance" between the tow. Distance is not literal (spatial) distance but more generally the difference between the two measured in some unit.
If the two tracks are equal in a certain sense their distance is zero, if the first argument is smaller than the second (again, in the sense of the (concrete) comparator) their distance is negative, positive otherwise. Example: compare two tracks by duration Track 1 (t1): duration 1200 Track 2 (t2): duration 1300
Calling compare of a by-duration-comparator: compare(t1,t2) would return a negative number (since t1 is shorter than t2)
Comparators may choose to handle comparison of null tracks but are not forced to.
- Parameters:
t1- the one track to comparet2- the other track to which t1 is to be compared- Returns:
- a measure of the distance between t1 and t2 in the sense of the comparator
-
-